package jielong

import (
	"youdu/common/crypt"
	"youdu/service/yodoo/sso"

	"github.com/gin-gonic/gin"
)

func Index(c *gin.Context) {
	c.HTML(200, "jielong_index.html", gin.H{"title": "群接龙 - 首页", "AccessToken": "456"})
}

func Add(c *gin.Context) {
	username := sso.CurrentUserName(c)
	c.HTML(200, "jielong_add.html", gin.H{
		"title":       "群接龙 - 新建",
		"AccessToken": "456",
		"username":    username,
	})
}
func Show(c *gin.Context) {
	// 有空研究下能不能像 thinkphp 那样全局 assign 给模板
	username := sso.CurrentUserName(c)
	u := sso.CurrentUser(c)
	c.HTML(200, "jielong_show.html", gin.H{
		"title":       "群接龙 - 详情",
		"AccessToken": "456",
		"id":          c.Param("id"),
		"username":    username,
		"user":        u,
	})
}

func ShowFromX(c *gin.Context) {
	username := sso.CurrentUserName(c)
	u := sso.CurrentUser(c)
	x := c.Param("x")
	id, err := crypt.Base64DecodeWithUrlSafe(x)
	if err != nil {
		panic(err)
	}
	c.HTML(200, "jielong_show.html", gin.H{
		"title":       "群接龙 - 详情",
		"AccessToken": "456",
		"id":          id,
		"username":    username,
		"user":        u,
	})
}
